import { Subscription, take, filter } from 'rxjs';
import { ReactiveProperty } from './ReactiveProperty';
import { Asap } from './CreatorSchedule';
import { _decorator } from 'cc';
import { EDITOR } from 'cc/env';
const { ccclass, property, float } = _decorator;

@ccclass('ReactiveBoolean')
export class ReactiveBoolean extends ReactiveProperty<boolean> {

    constructor() {
        super();
        this.init(this.Value);
    }

    static DefaultValue(value?: boolean): ReactiveBoolean {
        if (EDITOR) {
            let rp = new ReactiveBoolean();
            if (value != null) rp.Value = value;
            return rp;
        }
    }

    @property
    private _Value: boolean = false;
    @property
    public get Value(): boolean { return this._Value; }
    public set Value(v: boolean) { this._Value = v; if (this._subject) this.value = v; }

    loadValue() {
        this.value = this.Value;
    }
}

